<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>视差滚动</title>
    <style>
        body {
            padding: 0;
            margin: 0;
        }

        section {
            background-image: url("https://picsum.photos/200/300");
            width: 100%;
            height: 100vh;
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        h1 {
            margin: auto;
            font-size: 100px;
            color: #fff;
        }
    </style>
</head>
<body>
<!--https://picsum.photos/200/300-->
<section>
    <h1>HELLO WORLD</h1>
</section>
<section>
    <h1>HELLO WORLD</h1>
</section>
<section>
    <h1>HELLO WORLD</h1>
</section>
<section>
    <h1>HELLO WORLD</h1>
</section>
<section>
    <h1>HELLO WORLD</h1>
</section>


<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/ScrollTrigger.min.js"></script>

<script>
    gsap.registerPlugin(ScrollTrigger)
    const sections = document.querySelectorAll('section')
    sections.forEach(se => {
        gsap.fromTo(se, {
            backgroundPositionY: `-${window.innerHeight / 2}px`
        }, {
            backgroundPositionY: `-${window.innerHeight / 2}px`,
            duration: 3,
            ease: ' none',
            scrollTrigger: {
                trigger: se,
                scrub: true
            }
        })
    })
</script>
</body>
</html>